package org.chen.ctrip.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.chen.common.ctrip.entity.ProductMultilang;

import java.util.List;

@Mapper
public interface ProductMultilangMapper extends BaseMapper<ProductMultilang> {

    /**
     * 根据产品ID和语言代码查询多语言内容
     */
    @Select("SELECT * FROM ctrip_product_multilang WHERE product_id = #{productId} AND language_code = #{languageCode}")
    ProductMultilang selectByProductIdAndLanguage(@Param("productId") String productId, 
                                                  @Param("languageCode") String languageCode);

    /**
     * 根据产品ID查询所有语言版本
     */
    @Select("SELECT * FROM ctrip_product_multilang WHERE product_id = #{productId}")
    List<ProductMultilang> selectAllByProductId(@Param("productId") String productId);

    /**
     * 删除指定产品的指定语言内容
     */
    @Delete("DELETE FROM ctrip_product_multilang WHERE product_id = #{productId} AND language_code = #{languageCode}")
    int deleteByProductIdAndLanguage(@Param("productId") String productId, 
                                     @Param("languageCode") String languageCode);

    /**
     * 删除指定产品的所有语言内容
     */
    @Delete("DELETE FROM ctrip_product_multilang WHERE product_id = #{productId}")
    int deleteAllByProductId(@Param("productId") String productId);
}